package command;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Get the message from xxxx.properties, such as xxx_en_US.properties,
 * xxx_zh_cn.properties .... <br>
 * @author Jeff Zhuo
 *
 */
public class Language {
	
	private final String RESOURCE_NAME;
	
	private ResourceBundle bundle;
	private Locale locale;
	
	/**
	 * 
	 * @param properties The properties file
	 * @param locale locale of the properties
	 */
	public Language(String properties, Locale locale) {
		RESOURCE_NAME = properties;
		this.locale = locale;
		this.bundle = ResourceBundle.getBundle(RESOURCE_NAME, this.locale);
	}
	
	/**
	 * Set the locale
	 * @param locale
	 */
	public void setLocal(Locale locale) {
		this.locale = locale;
		this.bundle = ResourceBundle.getBundle(RESOURCE_NAME, this.locale);
	}
	
	/**
	 * Get the string by key
	 * @param key Localization Identifier
	 * @return Localization string
	 */
	public String getString(String key) {
		return bundle.getString(key);
	}
	
}
